package site.jlopen.components.entity;

import java.util.ArrayList;
import java.util.List;

public class GraphNodeParamCopy {

	public GraphNodeParam init(GraphNodeParam def) {
		GraphNodeParam info = new GraphNodeParam();
		info.setProjectId(def.getProjectId());
		info.setFlowId(def.getFlowId());
		info.setGraphId(def.getGraphId());
		info.setCode(def.getCode());
		info.setName(def.getName());
		info.setDomain(def.getDomain());
		info.setDesc(def.getDesc());
		info.setVersion(def.getVersion());
		info.setAttrs(getAttr(def.getAttrs()));
		info.setInds(def.getInds());
		info.setOutds(def.getOutds());
		return info;
	}
	
	private List<GraphNodeAttr> getAttr(List<GraphNodeAttr> list){
		List<GraphNodeAttr> attrs = new ArrayList<GraphNodeAttr>();
		if(null != list && list.size() > 0) {
			for (GraphNodeAttr attr : list) {
				GraphNodeAttr newattr = new GraphNodeAttr();
				newattr.setProp(attr.getProp());
				newattr.setCode(attr.getCode());
				newattr.setName(attr.getName());
				newattr.setDesc(attr.getDesc());
				newattr.setType(attr.getType());
				newattr.setRequired(attr.isRequired());
				newattr.setDefVal(attr.getDefVal());
				newattr.setPossible(attr.getPossible());
				newattr.setMax(attr.getMax());
				newattr.setMin(attr.getMin());
				attrs.add(newattr);
			}
		}
		return attrs;
	}
	
}
